package southwind.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import southwind.entity.User;
import southwind.service.UserService;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserHandler {
    @Autowired
    private UserService userService;

    @GetMapping("/findAll")
    @ResponseBody
    public List<User> findAll(){

        List<User> all = userService.findAll();
        for (User user : all) {
            System.out.println(user);
        }

        return all;
    }
    @GetMapping("/hello")
    @ResponseBody
    public String hello(){

        return "hello";
    }

}
